
import Vue from 'vue';
import Vuex from 'vuex';
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex);
const store =  {
    state: {
        userInfo:{},//用户信息
        token:"",//用户标识
        checkedUser:[],//选中的用户
        flag: "",
        opt:[]
    },
    mutations: {
        setFlag(state,data){
            state.flag = data
        },
        setOpt(state,data){
            state.opt = data
        },
        setUserInfo(state,data){
            state.userInfo = data;
            state.token = data.usertoken;
        },
        
        checkUser(state,data){
            console.log('传过来的check',data)
            state.checkedUser = data;
            console.log('state.checkUser',state.checkedUser)
        }
    },
    actions: {
  
    },
    getters: {
        "userInfo":state=>state.userInfo,
        "token":state=>state.token,
        "checkedUser":state=>state.checkedUser,
        "flag": state=> state.flag,
        "opt": state=> state.opt
    },  
    modules:{
    },
};
export default new Vuex.Store({
    ...store,
    plugins: [createPersistedState({
        storage: window.sessionStorage
    })]
});
